package com.congee02.dp.stair.climbStairs;

public class ClimbStairs_DP {

    public int climbStairs(int n) {

        int[] dp = new int[n + 1];

        dp[n] = 1;

        for (int i = n - 1 ; i >= 0 ; i -- ) {
            dp[i] = f(dp, i + 1) + f(dp, i + 2);
        }

        return dp[0];
    }

    private int f(int[] dp, int index) {
        if (index >= dp.length) {
            return 0;
        }
        return dp[index];
    }

}
